home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Visual Basic 6.0 Utilities / Multi-Language Add-In for Visual Basic 6.0 / MultiLang.msi / _AF3F81324EF811D5BEBE0020182C1E5C (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-04-24  |  14.9 KB  |  449 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
  4. Begin VB.Form frmMain 
  5.    Caption         =   "SimpleEditor"
  6.    ClientHeight    =   2484
  7.    ClientLeft      =   132
  8.    ClientTop       =   708
  9.    ClientWidth     =   3744
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   2484
  12.    ScaleWidth      =   3744
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin VB.TextBox Text1 
  15.       BeginProperty Font 
  16.          Name            =   "Courier New"
  17.          Size            =   10.2
  18.          Charset         =   0
  19.          Weight          =   400
  20.          Underline       =   0   'False
  21.          Italic          =   0   'False
  22.          Strikethrough   =   0   'False
  23.       EndProperty
  24.       Height          =   1452
  25.       Left            =   1200
  26.       MultiLine       =   -1  'True
  27.       ScrollBars      =   3  'Both
  28.       TabIndex        =   2
  29.       Top             =   480
  30.       Width           =   2412
  31.    End
  32.    Begin MSComctlLib.Toolbar tbToolBar 
  33.       Align           =   1  'Align Top
  34.       Height          =   336
  35.       Left            =   0
  36.       TabIndex        =   1
  37.       Top             =   0
  38.       Width           =   3744
  39.       _ExtentX        =   6604
  40.       _ExtentY        =   593
  41.       ButtonWidth     =   487
  42.       Appearance      =   1
  43.       ImageList       =   "imlToolbarIcons"
  44.       _Version        =   393216
  45.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  46.          NumButtons      =   7
  47.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  48.             Key             =   "New"
  49.             Object.ToolTipText     =   "New"
  50.             ImageKey        =   "New"
  51.          EndProperty
  52.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  53.             Key             =   "Open"
  54.             Object.ToolTipText     =   "Open"
  55.             ImageKey        =   "Open"
  56.          EndProperty
  57.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  58.             Key             =   "Save"
  59.             Object.ToolTipText     =   "Save"
  60.             ImageKey        =   "Save"
  61.          EndProperty
  62.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  63.             Style           =   3
  64.          EndProperty
  65.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  66.             Key             =   "Cut"
  67.             Object.ToolTipText     =   "Cut"
  68.             ImageKey        =   "Cut"
  69.          EndProperty
  70.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  71.             Key             =   "Copy"
  72.             Object.ToolTipText     =   "Copy"
  73.             ImageKey        =   "Copy"
  74.          EndProperty
  75.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  76.             Key             =   "Paste"
  77.             Object.ToolTipText     =   "Paste"
  78.             ImageKey        =   "Paste"
  79.          EndProperty
  80.       EndProperty
  81.    End
  82.    Begin MSComDlg.CommonDialog dlgCommonDialog 
  83.       Left            =   120
  84.       Top             =   360
  85.       _ExtentX        =   677
  86.       _ExtentY        =   677
  87.       _Version        =   393216
  88.    End
  89.    Begin MSComctlLib.StatusBar sbStatusBar 
  90.       Align           =   2  'Align Bottom
  91.       Height          =   264
  92.       Left            =   0
  93.       TabIndex        =   0
  94.       Top             =   2220
  95.       Width           =   3744
  96.       _ExtentX        =   6604
  97.       _ExtentY        =   466
  98.       _Version        =   393216
  99.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  100.          NumPanels       =   3
  101.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  102.             AutoSize        =   1
  103.             Text            =   "Status"
  104.             TextSave        =   "Status"
  105.          EndProperty
  106.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  107.             Style           =   6
  108.             AutoSize        =   2
  109.             TextSave        =   "23.04.01"
  110.          EndProperty
  111.          BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  112.             Style           =   5
  113.             AutoSize        =   2
  114.             TextSave        =   "22:43"
  115.          EndProperty
  116.       EndProperty
  117.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  118.          Name            =   "MS Sans Serif"
  119.          Size            =   7.8
  120.          Charset         =   0
  121.          Weight          =   400
  122.          Underline       =   0   'False
  123.          Italic          =   0   'False
  124.          Strikethrough   =   0   'False
  125.       EndProperty
  126.    End
  127.    Begin MSComctlLib.ImageList imlToolbarIcons 
  128.       Left            =   600
  129.       Top             =   360
  130.       _ExtentX        =   804
  131.       _ExtentY        =   804
  132.       BackColor       =   -2147483643
  133.       ImageWidth      =   16
  134.       ImageHeight     =   16
  135.       MaskColor       =   12632256
  136.       _Version        =   393216
  137.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  138.          NumListImages   =   6
  139.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  140.             Picture         =   "frmMain.frx":0000
  141.             Key             =   "New"
  142.          EndProperty
  143.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  144.             Picture         =   "frmMain.frx":0112
  145.             Key             =   "Open"
  146.          EndProperty
  147.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  148.             Picture         =   "frmMain.frx":0224
  149.             Key             =   "Save"
  150.          EndProperty
  151.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  152.             Picture         =   "frmMain.frx":0336
  153.             Key             =   "Cut"
  154.          EndProperty
  155.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  156.             Picture         =   "frmMain.frx":0448
  157.             Key             =   "Copy"
  158.          EndProperty
  159.          BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  160.             Picture         =   "frmMain.frx":055A
  161.             Key             =   "Paste"
  162.          EndProperty
  163.       EndProperty
  164.    End
  165.    Begin VB.Menu mnuFile 
  166.       Caption         =   "&File"
  167.       Begin VB.Menu mnuFileNew 
  168.          Caption         =   "&New"
  169.          Shortcut        =   ^N
  170.       End
  171.       Begin VB.Menu mnuFileOpen 
  172.          Caption         =   "&Open..."
  173.       End
  174.       Begin VB.Menu mnuFileClose 
  175.          Caption         =   "&Close"
  176.       End
  177.       Begin VB.Menu mnuFileBar0 
  178.          Caption         =   "-"
  179.       End
  180.       Begin VB.Menu mnuFileSave 
  181.          Caption         =   "&Save"
  182.       End
  183.       Begin VB.Menu mnuFileSaveAs 
  184.          Caption         =   "Save &As..."
  185.       End
  186.       Begin VB.Menu mnuFileBar1 
  187.          Caption         =   "-"
  188.       End
  189.       Begin VB.Menu mnuFileExit 
  190.          Caption         =   "E&xit"
  191.       End
  192.    End
  193.    Begin VB.Menu mnuEdit 
  194.       Caption         =   "&Edit"
  195.       Begin VB.Menu mnuEditCut 
  196.          Caption         =   "Cu&t"
  197.          Shortcut        =   ^X
  198.       End
  199.       Begin VB.Menu mnuEditCopy 
  200.          Caption         =   "&Copy"
  201.          Shortcut        =   ^C
  202.       End
  203.       Begin VB.Menu mnuEditPaste 
  204.          Caption         =   "&Paste"
  205.          Shortcut        =   ^V
  206.       End
  207.    End
  208.    Begin VB.Menu mnuView 
  209.       Caption         =   "&View"
  210.       Begin VB.Menu mnuViewToolbar 
  211.          Caption         =   "&Toolbar"
  212.          Checked         =   -1  'True
  213.       End
  214.       Begin VB.Menu mnuViewStatusBar 
  215.          Caption         =   "Status &Bar"
  216.          Checked         =   -1  'True
  217.       End
  218.    End
  219.    Begin VB.Menu mnuTools 
  220.       Caption         =   "&Tools"
  221.    End
  222.    Begin VB.Menu mnuHelp 
  223.       Caption         =   "&Help"
  224.       Begin VB.Menu mnuHelpAbout 
  225.          Caption         =   "&About "
  226.       End
  227.    End
  228. Attribute VB_Name = "frmMain"
  229. Attribute VB_GlobalNameSpace = False
  230. Attribute VB_Creatable = False
  231. Attribute VB_PredeclaredId = True
  232. Attribute VB_Exposed = False
  233. Option Explicit
  234. '-------------------------------------------------------------------------------
  235. 'API declarations
  236. '-------------------------------------------------------------------------------
  237. Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
  238. Private Const SW_SHOWNORMAL = 1
  239. Private Const SW_SHOWMINIMIZED = 2
  240. Private Const SW_SHOWMAXIMIZED = 3
  241. Private Type POINTAPI
  242.         x As Long
  243.         y As Long
  244. End Type
  245. Private Type RECT
  246.         Left As Long
  247.         Top As Long
  248.         Right As Long
  249.         Bottom As Long
  250. End Type
  251. Private Type WINDOWPLACEMENT
  252.         Length As Long
  253.         flags As Long
  254.         showCmd As Long
  255.         ptMinPosition As POINTAPI
  256.         ptMaxPosition As POINTAPI
  257.         rcNormalPosition As RECT
  258. End Type
  259. Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
  260. Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
  261. '-------------------------------------------------------------------------------
  262. 'End of API declarations
  263. '-------------------------------------------------------------------------------
  264. Private fso As New FileSystemObject
  265. Private sFile As String
  266. Private bDirty As Boolean
  267. Private Sub Form_Load()
  268.   'If you want to copy anything from this program, this is the most useful feature.
  269.   'Using GetWindowPlacement and SetWindowPlacement enable you so save the normal
  270.   'position of the window correctly, even if the window is maximised.
  271.   Dim wp As WINDOWPLACEMENT
  272.   GetWindowPlacement hwnd, wp
  273.   wp.rcNormalPosition.Top = GetSetting(App.Title, "Settings", "MainTop", 100)
  274.   wp.rcNormalPosition.Left = GetSetting(App.Title, "Settings", "MainLeft", 100)
  275.   wp.rcNormalPosition.Bottom = GetSetting(App.Title, "Settings", "MainBottom", 500)
  276.   wp.rcNormalPosition.Right = GetSetting(App.Title, "Settings", "MainRight", 500)
  277.   wp.showCmd = GetSetting(App.Title, "Settings", "MainState", SW_SHOWNORMAL)
  278.   SetWindowPlacement hwnd, wp
  279.   'Extra resize, because SetWindowPlacement causes the toolbar to be too high.
  280.   'You can't win 'em all!
  281.   DoEvents
  282.   Form_Resize
  283. End Sub
  284. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  285.   'Save file if dirty flag is set
  286.   Dim Response As VbMsgBoxResult
  287.   Response = PromptIfDirty
  288.   If Response = vbCancel Then
  289.     Cancel = 1
  290.   End If
  291. End Sub
  292. Private Sub Form_Resize()
  293.   Dim ClientTop As Long
  294.   Dim ClientHeight As Long
  295.   If mnuViewToolbar.Checked Then
  296.     ClientTop = tbToolBar.Height
  297.   Else
  298.     ClientTop = 0
  299.   End If
  300.   If mnuViewStatusBar.Checked Then
  301.     ClientHeight = Me.ScaleHeight - ClientTop - sbStatusBar.Height
  302.   Else
  303.     ClientHeight = Me.ScaleHeight - ClientTop
  304.   End If
  305.   Text1.Move 0, ClientTop, Me.ScaleWidth, ClientHeight
  306. End Sub
  307. Private Sub Form_Unload(Cancel As Integer)
  308.   Dim i As Integer
  309.   'close all sub forms
  310.   For i = Forms.Count - 1 To 1 Step -1
  311.     Unload Forms(i)
  312.   Next
  313.   'Window position.
  314.   'GetWindowPlacement() get the normal position when the window is maximised.
  315.   Dim wp As WINDOWPLACEMENT
  316.   GetWindowPlacement hwnd, wp
  317.   If wp.showCmd = SW_SHOWMINIMIZED Then
  318.     wp.showCmd = SW_SHOWNORMAL
  319.   End If
  320.   SaveSetting App.Title, "Settings", "MainLeft", wp.rcNormalPosition.Left
  321.   SaveSetting App.Title, "Settings", "MainTop", wp.rcNormalPosition.Top
  322.   SaveSetting App.Title, "Settings", "MainRight", wp.rcNormalPosition.Right
  323.   SaveSetting App.Title, "Settings", "MainBottom", wp.rcNormalPosition.Bottom
  324.   SaveSetting App.Title, "Settings", "MainState", wp.showCmd
  325. End Sub
  326. Private Sub tbToolBar_ButtonClick(ByVal Button As MSComCtlLib.Button)
  327.   On Error Resume Next
  328.   Select Case Button.Key
  329.     Case "New"
  330.       mnuFileNew_Click
  331.     Case "Open"
  332.       mnuFileOpen_Click
  333.     Case "Save"
  334.       mnuFileSave_Click
  335.     Case "Cut"
  336.       mnuEditCut_Click
  337.     Case "Copy"
  338.       mnuEditCopy_Click
  339.     Case "Paste"
  340.       mnuEditPaste_Click
  341.   End Select
  342. End Sub
  343. Private Sub mnuHelpAbout_Click()
  344.   frmAbout.Show vbModal, Me
  345. End Sub
  346. Private Sub mnuViewStatusBar_Click()
  347.   mnuViewStatusBar.Checked = Not mnuViewStatusBar.Checked
  348.   sbStatusBar.Visible = mnuViewStatusBar.Checked
  349.   Form_Resize
  350. End Sub
  351. Private Sub mnuViewToolbar_Click()
  352.   mnuViewToolbar.Checked = Not mnuViewToolbar.Checked
  353.   tbToolBar.Visible = mnuViewToolbar.Checked
  354.   Form_Resize
  355. End Sub
  356. Private Sub mnuEditPaste_Click()
  357.   Text1.SelText = Clipboard.GetText()
  358. End Sub
  359. Private Sub mnuEditCopy_Click()
  360.   Clipboard.Clear
  361.   Clipboard.SetText Text1.SelText
  362. End Sub
  363. Private Sub mnuEditCut_Click()
  364.   Clipboard.Clear
  365.   Clipboard.SetText Text1.SelText
  366.   Text1.SelText = ""
  367. End Sub
  368. Private Sub mnuFileExit_Click()
  369.   'unload the form
  370.   Unload Me
  371. End Sub
  372. Private Sub mnuFileSaveAs_Click()
  373.   With dlgCommonDialog
  374.     .DialogTitle = "Save"
  375.     .CancelError = False
  376.     .Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt"
  377.     .FilterIndex = 2
  378.     .ShowSave
  379.     If Len(.FileName) = 0 Then
  380.       Exit Sub
  381.     End If
  382.     sFile = .FileName
  383.   End With
  384.   Dim txt As TextStream
  385.   Set txt = fso.CreateTextFile(sFile)
  386.   txt.Write Text1.Text
  387. End Sub
  388. Private Sub mnuFileSave_Click()
  389.   If sFile = "" Then
  390.     mnuFileSaveAs_Click
  391.   Else
  392.     Dim txt As TextStream
  393.     Set txt = fso.CreateTextFile(sFile)
  394.     txt.Write Text1.Text
  395.   End If
  396. End Sub
  397. Private Sub mnuFileClose_Click()
  398.   'Its a stupid menu item. Close and New are identical!
  399.   mnuFileNew_Click
  400. End Sub
  401. Private Sub mnuFileOpen_Click()
  402.   With dlgCommonDialog
  403.     .DialogTitle = "Open"
  404.     .CancelError = False
  405.     .Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt"
  406.     .FilterIndex = 2
  407.     .ShowOpen
  408.     If Len(.FileName) = 0 Then
  409.       Exit Sub
  410.     End If
  411.     sFile = .FileName
  412.   End With
  413.   'Put the file name in the title bar
  414.   Me.Caption = App.Title & " - " & sFile
  415.   'Read the file
  416.   Dim txt As TextStream
  417.   Set txt = fso.OpenTextFile(sFile)
  418.   Text1.Text = txt.ReadAll
  419.   'Clear the dirty flag
  420.   bDirty = False
  421. End Sub
  422. Private Sub mnuFileNew_Click()
  423.   Dim Response As VbMsgBoxResult
  424.   'Save file if dirty flag is set
  425.   Response = PromptIfDirty
  426.   If Response <> vbCancel Then
  427.     'Clear the text
  428.     Text1.Text = ""
  429.     'Clear the dirty flag
  430.     bDirty = False
  431.   End If
  432. End Sub
  433. Private Sub Text1_Change()
  434.   bDirty = True
  435. End Sub
  436. Private Function PromptIfDirty() As VbMsgBoxResult
  437.   Dim Response As VbMsgBoxResult
  438.   If bDirty Then
  439.     Response = MsgBox("Save changes?", vbYesNoCancel, "SimpleEditor")
  440.     If Response = vbYes Then
  441.       mnuFileSave_Click
  442.       bDirty = False
  443.     End If
  444.   Else
  445.     Response = vbOK
  446.   End If
  447.   PromptIfDirty = Response
  448. End Function
  449.